let arr = [5, 6, 7, 8, 1, 2, 3];
let result = arr.reduce((preValue, currentValue) => {
  return preValue + currentValue;
});
console.log(result); //32

result = arr.reduce((preValue, currentValue) => {
  return preValue - currentValue;
});
console.log(arr);
console.log(result); //-26

let arr1 = [
  {
    name: 'zg',
    age: 18
  },
  {
    name: 'kobe',
    age: 35
  },
  {
    name: 'lucy',
    age: 22
  },
];
result = arr1.reduce((preValue, currentValue) => {
  return {
    name: preValue.name + currentValue.name,
    age: preValue.age + currentValue.age
  };
});
console.log(result); // {name: 'lucykobezg', age: 75}
